<?php

namespace app\model;

use app\traits\JwtAuthModelTrait;
use app\traits\ModelTrait;
use support\Redis;
use think\Model;

class SystemAdmin extends Model
{
    use ModelTrait;
    use JwtAuthModelTrait;

    //管理员列表
    public function getAllAdminList(): array
    {
        $key                = 'admin:systemAdmin:list';
        $adminUserListRedis = Redis::get($key);
        if ($adminUserListRedis) {
            return json_decode($adminUserListRedis, true);
        }

        $adminUserList    = SystemAdmin::getColumn([], 'username', 'id desc', 'id');
        $adminUserList[0] = '系统';
        Redis::set($key, json_encode($adminUserList), 'EX', 60 * 60 * 3, 1);
        return $adminUserList;
    }
}